"use strict";
cc._RF.push(module, '5e4ce6RbLRPtbf2yDw1w8lW', 'enemyPool');
// script/game/enemyPool.js

"use strict";

cc.Class({
  "extends": cc.Component,
  properties: {
    poolName: 'enemyPool',
    //initCount: 5,
    enemyPrefab: {
      "default": null,
      type: cc.Prefab
    }
  },
  // onLoad () {},
  start: function start() {
    this.enemyPool = new cc.NodePool();
    var initCount = 3;

    for (var i = 0; i < initCount; i++) {
      var enemy = cc.instantiate(this.enemyPrefab); //创建节点

      this.enemyPool.put(enemy); //放入对象池

      enemy.nodePool = this;
    }
  },
  //获取
  createEnemyPool: function createEnemyPool() {
    var enemy = null;

    if (this.enemyPool.size() > 0) {
      enemy = this.enemyPool.get();
    } else {
      enemy = cc.instantiate(this.enemyPrefab);
    }

    return enemy;
  },
  //返回
  onEnemyKilled: function onEnemyKilled(enemy) {
    this.enemyPool.put(enemy);
  } //  update (dt) {
  //  },

});

cc._RF.pop();